Split ErrorCodes/LSPErrorCodes and enforce ResponseMessage result xor error#7
Merged
Merged
Conversation
… error The LSP responseMessage spec defines two distinct error-code namespaces: ErrorCodes (JSON-RPC) and LSPErrorCodes (LSP-defined). They were merged into a single ErrorCodes enum. - Move RequestFailed / ServerCancelled / ContentModified / RequestCancelled and the LSP reserved-range markers into a new LSPErrorCodes enum; keep only JSON-RPC codes in ErrorCodes. - Add a ResponseMessage validator rejecting a message that carries both result and error, per the spec's "result MUST NOT exist on error". - Document ResponseError / ResponseMessage and both code enums; export LSPErrorCodes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
christiankissig
added a commit
that referenced
this pull request
Jul 7, 2026
Split ErrorCodes/LSPErrorCodes and enforce ResponseMessage result xor error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements
ResponseMessage,ResponseError, and the error-code enums per LSP 3.17 — Response Message.The spec defines two distinct error-code namespaces —
ErrorCodes(JSON-RPC defined) andLSPErrorCodes(LSP defined) — but the library merged them into oneErrorCodesenum. It also documents that a response'sresultMUST NOT be present when there is anerror, which was unenforced.Changes
ErrorCodeskeeps only the JSON-RPC codes (ParseError,InvalidRequest,MethodNotFound,InvalidParams,InternalError,ServerNotInitialized,UnknownErrorCode) and the JSON-RPC reserved-range markers (incl. theserverErrorStart/serverErrorEnddeprecated aliases).LSPErrorCodesenum carries the LSP-defined codes (RequestFailed,ServerCancelled,ContentModified,RequestCancelled) and the LSP reserved-range markers.ResponseMessagegains a validator rejecting a message that carries bothresultanderror.ResponseError,ResponseMessage, and both enums; exportLSPErrorCodesfromlsp_client.The LSP-defined codes have moved off
ErrorCodesontoLSPErrorCodes. Code referencingErrorCodes.RequestCancelled/.ContentModified/.ServerCancelled/.RequestFailed(or thelspReserved*markers) must now useLSPErrorCodes.*. This matches the spec's namespace separation.Testing
test_error_codes_valuesand added tests forLSPErrorCodesvalues, namespace separation, aResponseErrorbuilt from an LSP code, and the new result-xor-error validator.poetry run pytest(55 passed),ruff check,ruff format --check, andmypyall clean.🤖 Generated with Claude Code